package cn.jichangxiu.common.web.model.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;

import java.lang.reflect.Member;

@ToString
@ApiModel("返回对象操作代码")
public enum ResponseCode implements ResultCode {
    // 八百开头为操作成功代码
    SUCCESS(true , 800 , "操作成功！"),
    QUERY_SUCCESS(true , 801 , "查询成功！"),
    LOGIN_SUCCESS(true , 802 , "用户登录成功"),
    // 九百开头为操作失败代码
    FAIL(false , 900 , "操作失败！"),
    QUERY_FALL(false , 901 , "查询失败！"),
    FEGIN_FALL(false , 902 , "服务调用失败！"),
    LOGIN_FALL(false , 903 , "用户登录失败"),
    LOGIN_FALL_ACCOUNT_EMPTY(false , 9034 , "用户登录失败，用户名为空！"),
    LOGIN_FALL_PASSWORD_EMPTY(false , 905 , "用户登录失败，密码为空！"),
    LOGIN_FALL_ACCOUNT_ERROR(false , 906 , "用户登录失败，用户名错误！"),
    LOGIN_FALL_PASSWORD_ERROR(false , 907 , "用户登录失败，密码错误！"),
    TOKEN_TIME_OUT(false , 908 , "Token 过期了！"),
    NO_AUTH(false , 909 , "您，没有权限访问！"),
    ;

    @ApiModelProperty("操作是否成功")
    boolean success;
    @ApiModelProperty("操作代码")
    int code;
    @ApiModelProperty("提示信息")
    String message;

    private ResponseCode(boolean success, int code, String message){
        this.success = success;
        this.code = code;
        this.message = message;
    }

    @Override
    public boolean success() {
        return this.success;
    }

    @Override
    public int code() {
        return this.code;
    }

    @Override
    public String message() {
        return this.message;
    }
}
